package cn.swh.guguanjia.controller;

import cn.swh.guguanjia.entity.Result;
import cn.swh.guguanjia.entity.SysLog;
import cn.swh.guguanjia.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

//日志管理
@RestController
@RequestMapping("mapper/syslog")
public class LogController {
    /**
     * @return
     * @Description
     * @Params
     **/

    @Autowired
    SysLogService service;

    @RequestMapping("")
    public ModelAndView index() {
        return new ModelAndView("/log/log.html");
    }

    @RequestMapping("selectPage/{pageNum}/{pageSize}")
    public Result selectPage(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int  pageSize,
                             @RequestParam Map<String,Object>map) {
        return new Result(service.selectPage(pageNum, pageSize,map));
    }

    @RequestMapping("toUpdate")
    public ModelAndView toUpdate() {
        return new ModelAndView("/log/log-detail.html");
    }

    @RequestMapping(value = "doUpdate",method = RequestMethod.POST)
    public Result doUpdate(@RequestBody SysLog log) {
        return new Result(service.updateByPrimaryKeySelective(log));
    }
}
